import request from './request'
// mock数据库虚拟
import mockRequest from './mockRequest'
export const reqCategoryList = ()=>{
        return request({
            url:'/product/getBaseCategoryList',
            method:'get'
        })
}
export const reqGetBannerList = ()=>{
    return mockRequest({
        url:'/banner',
        method:'get'
    })
}
export const reqGetFloorList = ()=>{
    return mockRequest({
        url:'/floor',
        method:'get'
    })
}
export const reqGetSearchList = (data)=>{
    return request({
        url:'/list',
        method:'post',
        data
    })
}
export const reqGetDetailList = (skuId)=>{
    return request({
        url:`/item/${skuId}`,
        method:'get'
    })
}
// 添加到购物车
// /api/cart/addToCart/{ skuId }/{ skuNum }
export const reqAddToCart = (skuId,skuNum)=>{
    return request({
        url:`/cart/addToCart/${ skuId }/${ skuNum }`,
        method:'post'
    })
}
// 请求购物车的数据/api/cart/cartList
export const reqCartList = ()=>{
    return request({
        url:'/cart/cartList',
        method:'get'
    })
}
// 删除购物车的商品
// /api/cart/deleteCart/{skuId}
export const reqDeleteCart = (skuId)=>{
    return request({
        url:`/cart/deleteCart/${skuId}`,
        method:'delete'
    })
}
// 切换商品选中状态
// /api/cart/checkCart/{skuID}/{isChecked}
export const reqCheckCart = (skuId,isChecked)=>{
    return request({
        url:`cart/checkCart/${skuId}/${isChecked}`,
        method:'get'
    })
}
// 获取验证码
// /api/user/passport/sendCode/{phone}
export const reqSendCode = (phone)=>{
    return request({
        url:`/user/passport/sendCode/${phone}`,
        method:'get'
    })
}
// 注册用户
// /api/user/passport/register
export const reqRegister = (phone,code,password)=>{
    return request({
        url:'/user/passport/register',
        method:'post',
        data:{phone,code,password}
    })
}
// 用户登录 /api/user/passport/login
export const reqLogin = (phone,password)=>{
    // 返回的是Promise
    return request({
        url:'/user/passport/login',
        method:'post',
        // 请求体
        data:{phone,password}
    })
}
// 获取用户的信息/api/user/passport/auth/getUserInfo
export const reqUserInfo = ()=>{
    return request({
        url:'/user/passport/auth/getUserInfo',
        method:'get'
    })
}
// 退出登录/api/user/passport/logout
export const reqlogout = ()=>{
    return request({
        url:'/user/passport/logout',
        method:'get'
    })
}

// 获取用户地址
// /api/user/userAddress/auth/findUserAddressList
export const reqUserAddressList = ()=>{
    return request({
        url:'/user/userAddress/auth/findUserAddressList',
        method:'get'
    })
}

// 获取订单交易页的信息
// /api/order/auth/trade
export const reqTrade = ()=>{
    return request({
        url:'/order/auth/trade',
        method:'get'
    })
}
// 提交订单
// /api/order/auth/submitOrder?tradeNo={tradeNo}
export const reqSubmitOrder = (tradeNo,data)=>{
        return request({
            url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,
            method:'post',
            data
        })
}
// 获取订单支付信息
// /api/payment/weixin/createNative/{orderId}
export const reqCreateNative = (orderId)=>{
    return request({
        url:`/payment/weixin/createNative/${orderId}`,
        method:'get'
    })
}
// 查询支付状态
// /api/payment/weixin/queryPayStatus/{orderId}
export const  reqPayStatus = (orderId)=>{
    return request({
        url:`/payment/weixin/queryPayStatus/${orderId}`,
        method:'get'
    })
}